//
//  selectTableCell.m
//  TTAddressBook
//
//  Created by 贾政阳 on 12-1-13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "selectTableCell.h"

@implementation selectTableCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
		self.backgroundView = [[[UIView alloc] init] autorelease];
		self.backgroundView.backgroundColor = [UIColor whiteColor];
		self.textLabel.backgroundColor = [UIColor clearColor];
		self.detailTextLabel.backgroundColor = [UIColor clearColor];
        
        if (checkImageView == nil)
		{
			checkImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"choose.png"]];
			[self addSubview:checkImageView];
		}
		
		checkImageView.frame = CGRectMake(8, 10, 26, 26);

        
        if (contactImageView == nil) {
            contactImageView = [[UIImageView alloc] initWithFrame:CGRectMake(48, 4.5, 35, 35)];
            [self addSubview:contactImageView];
        }
        
        if (nameLabel == nil) {
//            CGRect cFrame = contactImageView.frame;
            nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(103, 0, 200, CGRectGetHeight(self.bounds))];
            [self addSubview:nameLabel];
        }
    }
    return self;
}



- (void)dealloc 
{
	[checkImageView release];
	checkImageView = nil;
    
    [contactImageView release];
    contactImageView = nil;
    
    [nameLabel release];
    nameLabel = nil;
    
    [super dealloc];
}


- (void) setChecked:(BOOL)checked
{
	if (checked)
	{
		checkImageView.image = [UIImage imageNamed:@"choose_on.png"];
		//self.backgroundView.backgroundColor = [UIColor colorWithRed:223.0/255.0 green:230.0/255.0 blue:250.0/255.0 alpha:1.0];
	}
	else
	{
		checkImageView.image = [UIImage imageNamed:@"choose.png"];
		//self.backgroundView.backgroundColor = [UIColor whiteColor];
	}
}

- (void) setContactName:(NSString*)name{
    nameLabel.text = name;
}

- (void) setContactImage:(UIImage*)image{
    contactImageView.image = image;
}

- (void) setContactImage:(UIImage*)contactImage contactName:(NSString*)name checked:(BOOL)checked{
    [self setContactImage:contactImage];
    [self setContactName:name];
    [self setChecked:checked];
    
}
@end
